package com.eastfair.questionnaire.service;

import com.eastfair.boot.service.SuperService;
import com.eastfair.questionnaire.dto.AnswerDTO;
import com.eastfair.questionnaire.dto.QuestionDTO;
import com.eastfair.questionnaire.entity.Answer;
import com.eastfair.questionnaire.vo.AnswerVO;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 业务接口
 * 答案
 * </p>
 *
 * @author yuwx
 * @date 2021-08-18
 */
public interface AnswerService extends SuperService<Answer> {
    /**
    *Description 查询问题下所有答案并排序
    *@Date 10:15 2021/8/25
    *@param projectId
    *@param questionId
    *@return java.util.List<com.eastfair.questionnaire.vo.AnswerVO>
    *@Author yuwx
    **/
    List<AnswerVO> list(Long projectId, Long questionId) ;
    /**
    *Description 根据答案id查询
    *@Date 16:41 2021/8/28
    *@param projectId
    *@param answerIdList
    *@return java.util.List<com.eastfair.questionnaire.vo.AnswerVO>
    *@Author yuwx
    **/
    List<AnswerVO> list(Long projectId, List<Long> answerIdList);
    /**
    *Description 查询问题下所有答案，按层级关系组合，结果排序
    *@Date 10:15 2021/8/25
    *@param projectId
    *@param questionId
    *@return java.util.List<com.eastfair.questionnaire.vo.AnswerVO>
    *@Author yuwx
    **/
    List<AnswerVO> listByLevel(Long projectId, Long questionId) ;
    /**
    *Description
     * 1.查询问题下所有答案，按层级关系组合，结果排序
     * 2.填充对象选择的结果
    *@Date 14:07 2021/8/25
    *@param projectId
    *@param questionId
    *@param subjectType
    *@param subjectId
    *@return java.util.List<com.eastfair.questionnaire.vo.AnswerVO>
    *@Author yuwx
    **/
    List<AnswerVO> listByLevel(Long projectId, Long questionId, String subjectType, Long subjectId) ;
    /**
    *Description 查询选中的答案
    *@Date 11:15 2021/9/15
    *@param projectId
    *@param questionIdList
    *@param subjectType
    *@param subjectId
    *@return java.util.List<com.eastfair.questionnaire.vo.AnswerVO>
    *@Author yuwx
    **/
    List<AnswerVO> listSelected(Long projectId, List<Long> questionIdList, String subjectType, Long subjectId);

    /**
    *Description 根据问题分组
    *@Date 10:23 2021/8/30
    *@param projectId
    *@param answerIdList
    *@return java.util.Map<java.lang.Long,com.eastfair.questionnaire.vo.AnswerVO>
    *@Author yuwx
    **/
    Map<Long, List<AnswerVO>> groupByQuestionId(Long projectId, List<Long> answerIdList);
    /**
    *Description 保存答案
    *@Date 11:34 2021/9/1
    *@param question
    *@param answerDTO
    *@return com.eastfair.questionnaire.vo.AnswerVO
    *@Author yuwx
    **/
    AnswerVO save(QuestionDTO question, AnswerDTO answerDTO);
    /**
    *Description
    *@Date 15:36 删除答案
    *@param projectId
    *@param answerId
    *@return void
    *@Author yuwx
    **/
    void delete(Long projectId, Long answerId);
    /**
    *Description 根据问题删除答案，带事务
    *@Date 15:37 2021/8/25
    *@param projectId
    *@param questionId
    *@return void
    *@Author yuwx
    **/
    void deleteByQuestion(Long projectId, Long questionId);

    /**
     *Description 判断是否是叶子节点
     *@Date 15:32 2021/8/25
     *@param answerVO
     *@return boolean
     *@Author yuwx
     **/
    boolean isLeafAnswer(AnswerVO answerVO);

    /**
     *Description 判断是否是顶级节点
     *@Date 15:33 2021/8/25
     *@param answerVO
     *@return boolean
     *@Author yuwx
     **/
    boolean isTopAnswer(AnswerVO answerVO);
}
